package cn.felord.verse.controller;

import cn.felord.common.kogito.dmn.DmnApplicationContext;
import cn.felord.security.autoconfigure.annotation.Anonymous;
import org.kie.kogito.dmn.rest.KogitoDMNResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping({"/User Score"})
public class UserScoreResource {
    @Autowired
    DmnApplicationContext applicationContext;

    public UserScoreResource() {
    }

    @PostMapping(
            value = {""},
            produces = {"application/json"},
            consumes = {"application/json"}
    )
    @Anonymous
    public KogitoDMNResult dmn(@RequestBody(required = false) Map<String, Object> variables) {
        String namespace = "https://kiegroup.org/dmn/_35671C72-1E3E-4606-9B92-DE617A45C2D1";
        String userScore = "User Score";
        return applicationContext.evaluate(namespace, userScore, variables);
    }
/*    {
        "User": {
        "ScoreLimit": 0,
                "Score": 0,
                "Level": "Silver",
                "Username": "string"
    },
        "ScoreEvent": {
        "Event": "UP"
    }
    }*/
}
